package 牛客;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * @author ZhuYi
 * @create 2025/4/10 11:15
 */
public class 小紫的劣势博弈 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n];
        String[] split = br.readLine().split(" ");
        for (int i = 0; i < split.length; i++) {
            a[i] = Integer.parseInt(split[i]);
        }
        Arrays.sort(a);
        int x = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 2 != 0) {
                x += a[i - 1];
            } else {
                x -= a[i - 1];
            }
        }
        System.out.println(x);
    }
}